#include "Assets.h"
#include "Logger.h"
#include "GameConfiguration.h"
#include "WindowManager.h"

extern Logger *logger;

MediaLoader Assets::media = MediaLoader();

Assets::Assets(void)
{
}

Assets::~Assets(void)
{
}

SDL_Texture* Assets::background = NULL;
SDL_Texture* Assets::player = NULL;
SDL_Texture* Assets::atlas = NULL;
SDL_Texture* Assets::trees = NULL;

void Assets::Release()
{
	SDL_DestroyTexture(background);
	SDL_DestroyTexture(atlas);
}

bool Assets::LoadAssets(void)
{
	media.Set_SDLRenderer();

	SDL_Surface *sky = SDL_CreateRGBSurface(0, gameconfig::SCREEN_WIDTH, gameconfig::SCREEN_HEIGHT * 2, 32, 0, 0, 255, 255);
	SDL_FillRect(sky, NULL, SDL_MapRGB(sky->format, 170, 219, 249));
	background = SDL_CreateTextureFromSurface(WindowManager::GetSRenderer(), sky);
	SDL_FreeSurface(sky);

	atlas = media.LoadImage("resources/atlas.png");
	trees = media.LoadImage("resources/trees.png");

	if (background == NULL || atlas == NULL)
	{
		return false;
	}
	return true;
}